Object.defineProperty(exports, "__esModule", {
  value: true
});
var def_GamePortalAdMgr = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.OnShowCallback = new Map();
    this.OnDestroyCallback = new Map();
    this.OnHideCallback = new Map();
    this._nativecomplat = new Map();
    this.GamePortalAds = new Map();
    this.isDestroy = true;
    this.isError = false;
    this.showing = -1;
    this.callback = null;
  }
  return babel_createClass(_ctor, [{
    key: "Create",
    value: function Create(e, t) {
      console.log("开始创建" + e);
      this.callback = t;
      if (!this.GamePortalAds.has(e)) {
        if (!(window.qg.getSystemInfoSync().platformVersionCode >= 1076 && window.qg.createGamePortalAd)) {
          return void console.log("快应用平台版本号低于1076，暂不支持互推盒子相关 API");
        }
        console.log("快应用平台版本号>=1076，支持互推盒子相关 API,开始创建" + e);
        var _t11 = window.qg.createGamePortalAd({
          adUnitId: e
        });
        _t11.onLoad(function () {
          console.log("互推盒子九宫格广告加载成功");
        });
        _t11.onClose(function () {
          console.log("互推盒子九宫格广告关闭");
          this.call && this.call();
        });
        _t11.onError(function (e) {
          console.log(e);
        });
        this.GamePortalAds.set(e, _t11);
        this.GamePortalAds.get(e).load().then(function () {
          console.log(" 九宫格游戏预加载成功");
        });
      }
    }
  }, {
    key: "CreateAndShow",
    value: function CreateAndShow(e, t) {
      this.Create(e, t);
      this.Show(e, t);
    }
  }, {
    key: "Show",
    value: function Show(e, t) {
      var _this38 = this;
      this.GamePortalAds.has(e) || this.CreateAndShow(e, t);
      this.GamePortalAds.get(e).load().then(function () {
        console.log("load success");
        _this38.GamePortalAds.get(e).show().then(function () {
          console.log("show success");
        }).catch(function (e) {
          console.log("show fail with:" + e.errCode + "," + e.errMsg);
        });
      }).catch(function (e) {
        console.log("load fail with:" + e.errCode + "," + e.errMsg);
      });
      this.OnShowCallback.has(e) && this.OnShowCallback.get(e)();
    }
  }, {
    key: "Destroy",
    value: function Destroy(e) {
      if (this.GamePortalAds.has(e)) {
        this.showing == e && (this.showing = -1);
        this.OnDestroyCallback.has(e) && this.OnDestroyCallback.get(e)();
        this.GamePortalAds.get(e).offLoad(function (e) {
          console.log(e);
        });
        this.GamePortalAds.get(e).offError(function (e) {
          console.log(e);
        });
        this.GamePortalAds.get(e).destroy().then(function () {
          console.log("destroy success");
        }).catch(function (e) {
          console.log("destroy fail with:" + e.errCode + "," + e.errMsg);
        });
        this.GamePortalAds.delete(e);
      }
    }
  }], [{
    key: "Instance",
    get() {
      _ctor._instance || (_ctor._instance = new _ctor());
      return _ctor._instance;
    }
  }]);
}();
exports.default = def_GamePortalAdMgr;